<?php
/**
 * This is the FireFeed Feed form.
 * 
 * @uses       Zend_Form
 * @package    FireFeed
 * @subpackage Form
 */
class Form_IndexBox extends Zend_Form
{
    /**
     * init() routine called when Zend_Form objects are created.
     * It make sense to define form elements in this method.
     * 
     * @see    http://framework.zend.com/manual/en/zend.form.html
     * @return void
     */ 
    public function init()
    {
        $this->setAction('/admin/addindexpagebox');
        $this->setMethod('POST');
        
        $this->setElementFilters(array('StringTrim'));
        
        $this->setAttrib('class', 'formstyle');
        $this->setAttrib('id', 'indexbox');

                
        $titlebox = new Zend_Form_Element_Text('title');
        $titlebox->setLabel('title')
                 ->setAttrib('class', 'field')
                 ->setAttrib('onkeyup','checkForRange(this, 4, 50);')
                 ->setAttrib('onclick','checkForRange(this, 4, 50);')
                 ->setDescription('msgTitle')
                 ->addValidator('StringLength', true, array('min' => '4', 'max' => '50'))
                 ->setDecorators(array(
                       array('ViewHelper', array('helper'=>'formText')),
                       array('Label', array('separator'=>' ', 'class'=>'gray labelfield')),
                       array('Errors'),
                       array('Description', array('tag' => 'span', 'class' => 'hint')),
                       array('HtmlTag', array('tag' => 'li', 'class' => 'element-group'))
                 ));
        
                       
        $feed = new Zend_Form_Element_Select('feed');
        $feed->setLabel('Feed:')
             ->setAttrib('class', 'field NoHints')
             ->setRequired(true)
             ->setRegisterInArrayValidator(false)
             ->setMultiOptions(array())
             ->setDecorators(array(
                   array('ViewHelper'),
                   array('Label', array('separator'=>' ', 'class'=>'gray labelfield')),
                   array('Errors')
             ));

        $category = new Zend_Form_Element_Select('category');
        $category->setLabel('category')
                 ->setAttrib('class', 'field NoHints')
                 ->setRequired(true)
                 ->setRegisterInArrayValidator(false)
                 ->setMultiOptions(array())
                 ->setDecorators(array(
                       array('ViewHelper'),
                       array('Label', array('separator'=>' ', 'class'=>'gray labelfield')),
                       array('Errors')
                 ));     

        $checkbox = new Zend_Form_Element_Checkbox('isPublished');
        $checkbox->setLabel('ispublished')
                 ->setDecorators(array( 
                   array('ViewHelper', array('helper'=>'formCheckbox')),
                   array('Label', array('class'=>'grey labelOpenid')),
                   array('HtmlTag', array('tag' => 'li', 'class' => 'element-group'))
                 ));     
        
        // Submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('save')
               ->setAttrib('class', 'profileSubmit')
               ->setDecorators(array(
                    array('ViewHelper'),
                    array('HtmlTag', array('tag' => 'li', 'class' => 'element-group'))
                 ));
        
        $this->addElements(array(
            $titlebox,
            $checkbox,
            $category,
            $feed,
            $submit
        ));
        
        $this->setDecorators(array(
            'FormElements',
            'Form'
        ));
    }
}